package com.hundsun.finance.service;

import java.io.InputStream;

import org.springframework.stereotype.Service;
import org.tinygroup.tinyscript.tree.impl.TreeDataNode;

import com.hundsun.finance.script.TinyScriptRunner;

@Service("stockService")
public class StockServiceImpl extends TinyScriptRunner implements StockService{

	public TreeDataNode insertStocks(InputStream input, String encode)
			throws Exception {
		TreeDataNode dataNode = (TreeDataNode) getScriptEngine().execute("StockService", "insertStocks", input,encode);
		return dataNode;
	}

	public TreeDataNode getStocks(String startDT, String endDT)
			throws Exception {
		TreeDataNode dataNode = (TreeDataNode) getScriptEngine().execute("StockService", "getStocks", startDT,endDT);
		return dataNode;
	}

	public TreeDataNode countPeriod(String period) throws Exception {
		TreeDataNode dataNode = (TreeDataNode) getScriptEngine().execute("StockService", "countPeriod", period);
		return dataNode;
	}

	public TreeDataNode countDays(String startDT, String endDT, Double riseMax,
			Double riseMin, Double fallMin, Double fallMax) throws Exception {
		TreeDataNode dataNode = (TreeDataNode) getScriptEngine().execute("StockService", "countDays", startDT,endDT,riseMax,riseMin,fallMin,fallMax);
		return dataNode;
	}

	public TreeDataNode countSeries(Integer limit, Double rate)
			throws Exception {
		TreeDataNode dataNode = (TreeDataNode) getScriptEngine().execute("StockService", "countSeries", limit,rate);
		return dataNode;
	}

}
